home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9716 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: bitfields, how big can their elements be?
  5. Date: 12 Mar 1996 22:00:28 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar12150028@qcd.lanl.gov>
  8. References: <4i2lab$ili@hobbes.cc.uga.edu> <TANMOY.96Mar12075107@qcd.lanl.gov>
  9.     <4i4c8dINNsde@keats.ugrad.cs.ubc.ca>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: c2a192@ugrad.cs.ubc.ca's message of 12 Mar 1996 09:28:45 -0800
  14.  
  15. In article <4i4c8dINNsde@keats.ugrad.cs.ubc.ca>
  16. c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  17.  
  18. KK: In article <TANMOY.96Mar12075107@qcd.lanl.gov>,
  19. KK: Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote:
  20. KK:  >In article <4i2lab$ili@hobbes.cc.uga.edu>
  21. KK:  >greear@pollux.cs.uga.edu (Ben Greear) writes:
  22. KK:  >
  23. KK:  >BG: 
  24. KK:  >BG: Ok, i have a question on bitfields....  How big can their members be,
  25. KK:  >
  26. KK:  >Eacm member is valid if its width is smaller than or equal to the
  27. KK:  >number of bits in an ordinary object of the corresponding type,
  28. KK:  >i.e. the number of bits in an int. This number may vary from
  29. KK:  >implementation to implementation, but is guaranteed to be at least 16. 
  30. KK: 
  31. KK: With GCC I tried making bitfields "long" and "short". This is an odd locution;
  32. KK: the compiler will actually prevent a "short" field from being more than 16
  33. KK: bits, but long can be 32. It's strange that the GNU compiler allows these
  34. KK: modifiers for bitfields! I'm going to have to look this up in the standard the
  35. KK: first chance I get.
  36.  
  37. The standard states that any type other than int and unsigned int for
  38. bitfields leads to undefined behaviour. So, the compiler is allowed to
  39. do anything it likes: including giving it a meaning.
  40.  
  41. Cheers
  42. Tanmoy
  43. --
  44. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  45. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  46. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  47. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  48. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  49. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  50.